<?php

namespace App\Modules\ImportDorisData\Factory;

use App\Modules\ImportDorisData\Factory\DorisTables\CallDetailTable;
use App\Modules\ImportDorisData\Factory\DorisTables\CallLogTable;
use App\Modules\ImportDorisData\Factory\DorisTables\CallResultTable;
use App\Modules\ImportDorisData\Factory\DorisTables\CallTaskTable;
use Swoole\Database\PDOPool;

class ImportDorisFactory
{
    /**
     * @var BaseTable
     */
    protected $table;

    public function __construct(string $table)
    {
        switch ($table) {
            case CallDetailTable::TYPE :
                $this->table = new CallDetailTable();
                break;
            case CallLogTable::TYPE :
                $this->table = new CallLogTable();
                break;
            case CallResultTable::TYPE :
                $this->table = new CallResultTable();
                break;
            case CallTaskTable::TYPE :
                $this->table = new CallTaskTable();
                break;
        }
    }

    public function importData(PDOPool $pool) : void
    {
        $this->table->importData($pool);
    }
}